/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.view.manager;

import group2assignone.ucm.manager.UCCancelAirport;
import group2assignone.func.UCCtoALAdapter;
import group2assignone.model.Airport;
import group2assignone.ucm.manager.UCDeleteAirport;
import group2assignone.view.*;

import java.util.ArrayList;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

/**
 *
 * @author Natalie
 */
public class DeleteAirportView extends OurView
{
     private JLabel title = new JLabel("Delete Flight");

    private JButton cancel = new JButton("Cancel");
    private JButton delete = new JButton("Delete");
    private AirportTableView airportView;
    private ArrayList<Airport> airportList;

    /*
     *Constructor.
     * Performs no function.
     */
    public DeleteAirportView(ArrayList<Airport> airportList)
    {
        this.airportList = airportList;
        airportView = new AirportTableView(airportList);
    }


    /*
     * Sets action listener for cancel button.
     * @param ActionListener al
     */
//    public void setCancelAL(ActionListener al) {
//        cancel.addActionListener(al);
//    }

    /*
     * Sets action listener for delete button.
     * @param ActionListener al
     */
//    public void setDeleteAL(ActionListener al) {
//        delete.addActionListener(al);
//    }

    /*
     * Adds all of the relevant components to the view.
     * Created view will allow flight number to be entered.
     */
    public void addComponents() {

        southPanel.add(cancel);
        southPanel.add(delete);

        centerPanel.add(airportView);

        centerPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        northPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
        southPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

        cancel.addActionListener(new UCCtoALAdapter(new UCCancelAirport(this)));
        delete.addActionListener(new UCCtoALAdapter(new UCDeleteAirport(this)));
        pack();
    }


    /**
     * this function returns the selected row number
     * this is to enable deleting and editing of the correct table row
     * @return
     */
    public String[] getRow() {
        return airportView.getRow();

    }

    /**
     * This function returns the string entered into the textfield Username
     * @return
     */
    public String getAirportLoc()
    {
        return airportView.getAirportLoc();
    }

    /**
     * This function is to set the selected row in program
     * @param row
     */
    public void setSelectedRow(int row)
    {
        airportView.setSelectedRow(row);
    }

    /**
     * this function is to return the private variable which holds the selected row
     * @return
     */
    public int getSelectedRow() {
        return airportView.getSelectedRow();
    }


}
